import Vue from 'vue'
import 'eventsource-polyfill'
import 'babel-polyfill'

// version
Vue.prototype.$version = '1.0.0.2'

// lodash
import lodash from 'lodash'
Vue.prototype.$lodash = Vue.lodash = lodash

// moment
import moment from 'moment'
Vue.prototype.$moment = Vue.moment = moment

// axios
import axios from 'axios'
Vue.prototype.$http = Vue.http = axios

import pinyin from 'chinese-to-pinyin'
Vue.prototype.$pinyin = Vue.pinyin = pinyin

import echarts from 'echarts'
Vue.prototype.$echarts = Vue.echarts = echarts

import CryptoJS from 'crypto-js'
Vue.prototype.$CryptoJS = Vue.CryptoJS = CryptoJS

// router and store
import store from './store'
import router from './router'
import {
  sync
} from 'vuex-router-sync'
sync(store, router)

import iView from 'iview'
import 'iview/dist/styles/iview.css'
Vue.use(iView)

import Vuelidate from 'vuelidate'
Vue.use(Vuelidate)

// ajax
import './http'

// main component
import App from './App'

import './socket'

const opt = {
  router,
  store,
  ...App // Object spread copying everything from App.vue
}
const app = new Vue(opt)
  // actually mount to DOM
app.$mount('#app')
window.onbeforeunload = function () {
  // 手动刷新前消毁app
  app.$destroy()
}
// disable context menu
// document.oncontextmenu = function(){return false;};
